{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from service.stock.common import LeastSquareMethod\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.cluster import AgglomerativeClustering\n",
    "from sklearn.cluster import KMeans\n",
    "import numpy as np\n",
    "from kneed import KneeLocator\n",
    "\n",
    "df = pd.read_csv(r'../service/requests/datas/000868.csv')\n",
    "df['date'] = pd.to_datetime(df['date'])\n",
    "df.set_index('date', inplace=True)\n",
    "\n",
    "df = df[['open', 'close', 'high', 'low', 'volume', 'pctChg', 'turn']]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = df['close'].tail(120).values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAF1CAYAAADx1LGMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAt/UlEQVR4nO3deZhU5Zn+8e8DAg2IoNgyjYigAgoIVNOgiKA/EJcoaFCjTnTQLBqTmGhmNDE6k+joJI5ZTDIZI3FBxbiECApRo6JmNC6kEUQWlSWgCELLvtPA8/vjVEMD3XR1d1W9daruz3X1VVWntjtc5u6333POe8zdERGR+GkSOoCIiDSMClxEJKZU4CIiMaUCFxGJKRW4iEhMqcBFRGJKBS6SJmY2x8xOD51DCocKXHKGmS02szOqPb7UzNaY2WkBcmwxs41mtsLMxpnZwXW9z917uftr9fiOM+p+pUjtVOCSk8xsDPBb4Fx3/2uACCPd/WCgFCgDbg2QQeSAVOCSc8zsGuDnwF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RiohIzTSFIiISUypwEZGYUoGLiMSUClxEJKZU4CIiMaUCFxGJKRW4iEhMqcBFRGLq/wNiI5JN8RhHQAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sum_of_sq_distances = []\n",
    "K = range(1, 10)\n",
    "for k in K:\n",
    "    km = KMeans(n_clusters=k)\n",
    "    km = km.fit(X.reshape(-1, 1))\n",
    "    sum_of_sq_distances.append(km.inertia_)\n",
    "kn = KneeLocator(K, sum_of_sq_distances, S=1.0, curve=\"convex\", direction=\"decreasing\")\n",
    "kn.plot_knee()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[6.1, 5.06], [9.0, 7.34], [7.02, 6.11]]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kmeans = KMeans(n_clusters=kn.knee).fit(X.reshape(-1, 1))\n",
    "c = kmeans.predict(X.reshape(-1, 1))\n",
    "min_and_max = []\n",
    "for i in range(kn.knee):\n",
    "    min_and_max.append([-np.inf, np.inf])\n",
    "for i in range(len(X)):\n",
    "    cluster = c[i]\n",
    "    if X[i] > min_and_max[cluster][0]:\n",
    "        min_and_max[cluster][0] = X[i]\n",
    "    if X[i] < min_and_max[cluster][1]:\n",
    "        min_and_max[cluster][1] = X[i]\n",
    "min_and_max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "df['volume_diff'] = (df['volume'] - df['volume'].shift(1)) / df['volume'].shift(1)\n",
    "\n",
    "df['VOL_M5'] = df['volume'].rolling(5).mean()\n",
    "df['VOL_M10'] = df['volume'].rolling(10).mean()\n",
    "\n",
    "df['vol_M5_diff'] = (df['volume'] - df['VOL_M5']) / df['VOL_M5']\n",
    "df['vol_M10_diff'] = (df['volume'] - df['VOL_M10']) / df['VOL_M10']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df[['close', 'volume', 'pctChg', 'volume_diff']]\n",
    "df_last = df.loc['2022']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 放量上涨\n",
    "df_sz = df_last[(df_last['volume_diff'] > 1) & (df_last['pctChg'] > 2)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 放量下跌\n",
    "df_xd = df_last[(df_last['volume_diff'] > 1) & (df_last['pctChg'] < -2)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 放量的定义:当日成交量在M5,M10上面都属于放量\n",
    "# df_last['vol_M5_diff']>\n",
    "# 缩量\n",
    "\n",
    "# 长期持平  最近两天成交量的斜率,最近三天斜率和最近五天斜率\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df_last.loc[(df_last['volume_diff'] > 1) & (df_last['pctChg'] > 2), 'vol_remark'] = '放量上涨'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "#df_last.loc[(df_last['volume_diff'] > 1) & (df_last['pctChg'] < -2), 'vol_remark'] = '放量下跌'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.mode.chained_assignment = None\n",
    "# 成交量得分\n",
    "# df_last['ranking'] = df_last['volume'].rolling(5).rank()\n",
    "# df_last['score'] = df_last['ranking'].map(lambda x: 2 * (x - 1) / 5 - 1)\n",
    "df_last['score_1'] = df_last['volume'].rolling(5).rank().map(lambda x: 2 * (x - 1) / 5 - 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>pctChg</th>\n",
       "      <th>volume_diff</th>\n",
       "      <th>score_1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-11-14</th>\n",
       "      <td>6.25</td>\n",
       "      <td>319726</td>\n",
       "      <td>-0.48</td>\n",
       "      <td>-0.350502</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-15</th>\n",
       "      <td>6.42</td>\n",
       "      <td>484904</td>\n",
       "      <td>2.72</td>\n",
       "      <td>0.516624</td>\n",
       "      <td>-0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-16</th>\n",
       "      <td>6.54</td>\n",
       "      <td>659480</td>\n",
       "      <td>1.87</td>\n",
       "      <td>0.360022</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-17</th>\n",
       "      <td>6.34</td>\n",
       "      <td>394612</td>\n",
       "      <td>-3.06</td>\n",
       "      <td>-0.401632</td>\n",
       "      <td>-0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-18</th>\n",
       "      <td>6.21</td>\n",
       "      <td>304048</td>\n",
       "      <td>-2.05</td>\n",
       "      <td>-0.229501</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-21</th>\n",
       "      <td>6.34</td>\n",
       "      <td>462843</td>\n",
       "      <td>2.09</td>\n",
       "      <td>0.522270</td>\n",
       "      <td>-0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-22</th>\n",
       "      <td>6.16</td>\n",
       "      <td>320260</td>\n",
       "      <td>-2.84</td>\n",
       "      <td>-0.308059</td>\n",
       "      <td>-0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-23</th>\n",
       "      <td>6.17</td>\n",
       "      <td>245559</td>\n",
       "      <td>0.16</td>\n",
       "      <td>-0.233251</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-24</th>\n",
       "      <td>6.13</td>\n",
       "      <td>220831</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-0.100701</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-25</th>\n",
       "      <td>5.90</td>\n",
       "      <td>310426</td>\n",
       "      <td>-3.75</td>\n",
       "      <td>0.405717</td>\n",
       "      <td>-0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-28</th>\n",
       "      <td>5.92</td>\n",
       "      <td>165487</td>\n",
       "      <td>0.34</td>\n",
       "      <td>-0.466904</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-29</th>\n",
       "      <td>6.05</td>\n",
       "      <td>235372</td>\n",
       "      <td>2.20</td>\n",
       "      <td>0.422299</td>\n",
       "      <td>-0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>6.66</td>\n",
       "      <td>1308828</td>\n",
       "      <td>10.08</td>\n",
       "      <td>4.560678</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-01</th>\n",
       "      <td>6.58</td>\n",
       "      <td>1518114</td>\n",
       "      <td>-1.20</td>\n",
       "      <td>0.159903</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-02</th>\n",
       "      <td>6.40</td>\n",
       "      <td>706959</td>\n",
       "      <td>-2.74</td>\n",
       "      <td>-0.534318</td>\n",
       "      <td>-0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-05</th>\n",
       "      <td>6.46</td>\n",
       "      <td>608283</td>\n",
       "      <td>0.94</td>\n",
       "      <td>-0.139578</td>\n",
       "      <td>-0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-06</th>\n",
       "      <td>6.56</td>\n",
       "      <td>764046</td>\n",
       "      <td>1.55</td>\n",
       "      <td>0.256070</td>\n",
       "      <td>-0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-07</th>\n",
       "      <td>6.44</td>\n",
       "      <td>576203</td>\n",
       "      <td>-1.83</td>\n",
       "      <td>-0.245853</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-08</th>\n",
       "      <td>6.36</td>\n",
       "      <td>431093</td>\n",
       "      <td>-1.24</td>\n",
       "      <td>-0.251838</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-09</th>\n",
       "      <td>6.23</td>\n",
       "      <td>366701</td>\n",
       "      <td>-2.04</td>\n",
       "      <td>-0.149369</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            close   volume  pctChg  volume_diff  score_1\n",
       "date                                                    \n",
       "2022-11-14   6.25   319726   -0.48    -0.350502     -1.0\n",
       "2022-11-15   6.42   484904    2.72     0.516624     -0.6\n",
       "2022-11-16   6.54   659480    1.87     0.360022      0.6\n",
       "2022-11-17   6.34   394612   -3.06    -0.401632     -0.6\n",
       "2022-11-18   6.21   304048   -2.05    -0.229501     -1.0\n",
       "2022-11-21   6.34   462843    2.09     0.522270     -0.2\n",
       "2022-11-22   6.16   320260   -2.84    -0.308059     -0.6\n",
       "2022-11-23   6.17   245559    0.16    -0.233251     -1.0\n",
       "2022-11-24   6.13   220831   -0.65    -0.100701     -1.0\n",
       "2022-11-25   5.90   310426   -3.75     0.405717     -0.2\n",
       "2022-11-28   5.92   165487    0.34    -0.466904     -1.0\n",
       "2022-11-29   6.05   235372    2.20     0.422299     -0.2\n",
       "2022-11-30   6.66  1308828   10.08     4.560678      0.6\n",
       "2022-12-01   6.58  1518114   -1.20     0.159903      0.6\n",
       "2022-12-02   6.40   706959   -2.74    -0.534318     -0.2\n",
       "2022-12-05   6.46   608283    0.94    -0.139578     -0.6\n",
       "2022-12-06   6.56   764046    1.55     0.256070     -0.2\n",
       "2022-12-07   6.44   576203   -1.83    -0.245853     -1.0\n",
       "2022-12-08   6.36   431093   -1.24    -0.251838     -1.0\n",
       "2022-12-09   6.23   366701   -2.04    -0.149369     -1.0"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_last.tail(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>pctChg</th>\n",
       "      <th>volume_diff</th>\n",
       "      <th>score</th>\n",
       "      <th>qxl</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-11-14</th>\n",
       "      <td>6.25</td>\n",
       "      <td>319726</td>\n",
       "      <td>-0.48</td>\n",
       "      <td>-0.350502</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-6.107411</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-15</th>\n",
       "      <td>6.42</td>\n",
       "      <td>484904</td>\n",
       "      <td>2.72</td>\n",
       "      <td>0.516624</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>-1.947306</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-16</th>\n",
       "      <td>6.54</td>\n",
       "      <td>659480</td>\n",
       "      <td>1.87</td>\n",
       "      <td>0.360022</td>\n",
       "      <td>0.6</td>\n",
       "      <td>2.748088</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-17</th>\n",
       "      <td>6.34</td>\n",
       "      <td>394612</td>\n",
       "      <td>-3.06</td>\n",
       "      <td>-0.401632</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>2.347812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-18</th>\n",
       "      <td>6.21</td>\n",
       "      <td>304048</td>\n",
       "      <td>-2.05</td>\n",
       "      <td>-0.229501</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-0.916654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-21</th>\n",
       "      <td>6.34</td>\n",
       "      <td>462843</td>\n",
       "      <td>2.09</td>\n",
       "      <td>0.522270</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-2.805249</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-22</th>\n",
       "      <td>6.16</td>\n",
       "      <td>320260</td>\n",
       "      <td>-2.84</td>\n",
       "      <td>-0.308059</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>-4.346124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-23</th>\n",
       "      <td>6.17</td>\n",
       "      <td>245559</td>\n",
       "      <td>0.16</td>\n",
       "      <td>-0.233251</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-2.233404</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-24</th>\n",
       "      <td>6.13</td>\n",
       "      <td>220831</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-0.100701</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.890075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-25</th>\n",
       "      <td>5.90</td>\n",
       "      <td>310426</td>\n",
       "      <td>-3.75</td>\n",
       "      <td>0.405717</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-5.199595</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-28</th>\n",
       "      <td>5.92</td>\n",
       "      <td>165487</td>\n",
       "      <td>0.34</td>\n",
       "      <td>-0.466904</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-4.289153</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-29</th>\n",
       "      <td>6.05</td>\n",
       "      <td>235372</td>\n",
       "      <td>2.20</td>\n",
       "      <td>0.422299</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-2.576572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>6.66</td>\n",
       "      <td>1308828</td>\n",
       "      <td>10.08</td>\n",
       "      <td>4.560678</td>\n",
       "      <td>0.6</td>\n",
       "      <td>6.899249</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-01</th>\n",
       "      <td>6.58</td>\n",
       "      <td>1518114</td>\n",
       "      <td>-1.20</td>\n",
       "      <td>0.159903</td>\n",
       "      <td>0.6</td>\n",
       "      <td>11.859779</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-02</th>\n",
       "      <td>6.40</td>\n",
       "      <td>706959</td>\n",
       "      <td>-2.74</td>\n",
       "      <td>-0.534318</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>8.474722</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-05</th>\n",
       "      <td>6.46</td>\n",
       "      <td>608283</td>\n",
       "      <td>0.94</td>\n",
       "      <td>-0.139578</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>3.205216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-06</th>\n",
       "      <td>6.56</td>\n",
       "      <td>764046</td>\n",
       "      <td>1.55</td>\n",
       "      <td>0.256070</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-1.832840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-07</th>\n",
       "      <td>6.44</td>\n",
       "      <td>576203</td>\n",
       "      <td>-1.83</td>\n",
       "      <td>-0.245853</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-0.687516</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-08</th>\n",
       "      <td>6.36</td>\n",
       "      <td>431093</td>\n",
       "      <td>-1.24</td>\n",
       "      <td>-0.251838</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-0.572939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-09</th>\n",
       "      <td>6.23</td>\n",
       "      <td>366701</td>\n",
       "      <td>-2.04</td>\n",
       "      <td>-0.149369</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.776045</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            close   volume  pctChg  volume_diff  score        qxl\n",
       "date                                                             \n",
       "2022-11-14   6.25   319726   -0.48    -0.350502   -1.0  -6.107411\n",
       "2022-11-15   6.42   484904    2.72     0.516624   -0.6  -1.947306\n",
       "2022-11-16   6.54   659480    1.87     0.360022    0.6   2.748088\n",
       "2022-11-17   6.34   394612   -3.06    -0.401632   -0.6   2.347812\n",
       "2022-11-18   6.21   304048   -2.05    -0.229501   -1.0  -0.916654\n",
       "2022-11-21   6.34   462843    2.09     0.522270   -0.2  -2.805249\n",
       "2022-11-22   6.16   320260   -2.84    -0.308059   -0.6  -4.346124\n",
       "2022-11-23   6.17   245559    0.16    -0.233251   -1.0  -2.233404\n",
       "2022-11-24   6.13   220831   -0.65    -0.100701   -1.0  -1.890075\n",
       "2022-11-25   5.90   310426   -3.75     0.405717   -0.2  -5.199595\n",
       "2022-11-28   5.92   165487    0.34    -0.466904   -1.0  -4.289153\n",
       "2022-11-29   6.05   235372    2.20     0.422299   -0.2  -2.576572\n",
       "2022-11-30   6.66  1308828   10.08     4.560678    0.6   6.899249\n",
       "2022-12-01   6.58  1518114   -1.20     0.159903    0.6  11.859779\n",
       "2022-12-02   6.40   706959   -2.74    -0.534318   -0.2   8.474722\n",
       "2022-12-05   6.46   608283    0.94    -0.139578   -0.6   3.205216\n",
       "2022-12-06   6.56   764046    1.55     0.256070   -0.2  -1.832840\n",
       "2022-12-07   6.44   576203   -1.83    -0.245853   -1.0  -0.687516\n",
       "2022-12-08   6.36   431093   -1.24    -0.251838   -1.0  -0.572939\n",
       "2022-12-09   6.23   366701   -2.04    -0.149369   -1.0  -3.776045"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import talib as tb\n",
    "\n",
    "# 斜率\n",
    "qxj = tb.LINEARREG_ANGLE(np.asarray(df['close']), timeperiod=5)  #计算趋势 倾斜角\n",
    "df['qxl'] = qxj\n",
    "df.tail(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_last = df_last[['close']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_last['close_1'] = df_last['close'].shift(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_last['close_2'] = df_last['close'].shift(-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 30日最高\n",
    "df_last['max_30'] = df_last['close'].rolling(30).max().bfill()\n",
    "df_last['min_30'] = df_last['close'].rolling(30).min().bfill()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>close_1</th>\n",
       "      <th>close_2</th>\n",
       "      <th>max_30</th>\n",
       "      <th>min_30</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-11-28</th>\n",
       "      <td>5.92</td>\n",
       "      <td>6.05</td>\n",
       "      <td>6.66</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-29</th>\n",
       "      <td>6.05</td>\n",
       "      <td>6.66</td>\n",
       "      <td>6.58</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>6.66</td>\n",
       "      <td>6.58</td>\n",
       "      <td>6.40</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-01</th>\n",
       "      <td>6.58</td>\n",
       "      <td>6.40</td>\n",
       "      <td>6.46</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-02</th>\n",
       "      <td>6.40</td>\n",
       "      <td>6.46</td>\n",
       "      <td>6.56</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-05</th>\n",
       "      <td>6.46</td>\n",
       "      <td>6.56</td>\n",
       "      <td>6.44</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-06</th>\n",
       "      <td>6.56</td>\n",
       "      <td>6.44</td>\n",
       "      <td>6.36</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-07</th>\n",
       "      <td>6.44</td>\n",
       "      <td>6.36</td>\n",
       "      <td>6.23</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-08</th>\n",
       "      <td>6.36</td>\n",
       "      <td>6.23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-09</th>\n",
       "      <td>6.23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.79</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            close  close_1  close_2  max_30  min_30\n",
       "date                                               \n",
       "2022-11-28   5.92     6.05     6.66    6.75    5.57\n",
       "2022-11-29   6.05     6.66     6.58    6.75    5.57\n",
       "2022-11-30   6.66     6.58     6.40    6.75    5.57\n",
       "2022-12-01   6.58     6.40     6.46    6.75    5.57\n",
       "2022-12-02   6.40     6.46     6.56    6.75    5.57\n",
       "2022-12-05   6.46     6.56     6.44    6.75    5.75\n",
       "2022-12-06   6.56     6.44     6.36    6.75    5.75\n",
       "2022-12-07   6.44     6.36     6.23    6.75    5.75\n",
       "2022-12-08   6.36     6.23      NaN    6.75    5.75\n",
       "2022-12-09   6.23      NaN      NaN    6.75    5.79"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_last.tail(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 新高\n",
    "df_last.loc[(df_last['close'] > df_last['close_1']) & (df_last['close'] >= df_last['close_2']) & (\n",
    "            df_last['close'] == df_last['max_30']), 'remark'] = '历史高点'\n",
    "df_last.loc[(df_last['close'] < df_last['close_1']) & (df_last['close'] <= df_last['close_2']) & (\n",
    "            df_last['close'] == df_last['min_30']), 'remark'] = '历史低点'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>close_1</th>\n",
       "      <th>close_2</th>\n",
       "      <th>max_30</th>\n",
       "      <th>min_30</th>\n",
       "      <th>remark</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-12-05</th>\n",
       "      <td>6.46</td>\n",
       "      <td>6.56</td>\n",
       "      <td>6.44</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-06</th>\n",
       "      <td>6.56</td>\n",
       "      <td>6.44</td>\n",
       "      <td>6.36</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-07</th>\n",
       "      <td>6.44</td>\n",
       "      <td>6.36</td>\n",
       "      <td>6.23</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-08</th>\n",
       "      <td>6.36</td>\n",
       "      <td>6.23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.75</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-09</th>\n",
       "      <td>6.23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6.75</td>\n",
       "      <td>5.79</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            close  close_1  close_2  max_30  min_30 remark\n",
       "date                                                      \n",
       "2022-12-05   6.46     6.56     6.44    6.75    5.75    NaN\n",
       "2022-12-06   6.56     6.44     6.36    6.75    5.75    NaN\n",
       "2022-12-07   6.44     6.36     6.23    6.75    5.75    NaN\n",
       "2022-12-08   6.36     6.23      NaN    6.75    5.75    NaN\n",
       "2022-12-09   6.23      NaN      NaN    6.75    5.79    NaN"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_last.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>close_1</th>\n",
       "      <th>close_2</th>\n",
       "      <th>max_30</th>\n",
       "      <th>min_30</th>\n",
       "      <th>remark</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-01-25</th>\n",
       "      <td>3.66</td>\n",
       "      <td>3.72</td>\n",
       "      <td>3.68</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>历史低点</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-28</th>\n",
       "      <td>3.45</td>\n",
       "      <td>3.61</td>\n",
       "      <td>3.57</td>\n",
       "      <td>5.15</td>\n",
       "      <td>3.45</td>\n",
       "      <td>历史低点</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-09</th>\n",
       "      <td>5.49</td>\n",
       "      <td>5.71</td>\n",
       "      <td>5.70</td>\n",
       "      <td>7.34</td>\n",
       "      <td>5.49</td>\n",
       "      <td>历史低点</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-10</th>\n",
       "      <td>5.71</td>\n",
       "      <td>5.88</td>\n",
       "      <td>6.19</td>\n",
       "      <td>9.00</td>\n",
       "      <td>5.71</td>\n",
       "      <td>历史低点</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-24</th>\n",
       "      <td>5.57</td>\n",
       "      <td>6.13</td>\n",
       "      <td>6.16</td>\n",
       "      <td>9.00</td>\n",
       "      <td>5.57</td>\n",
       "      <td>历史低点</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            close  close_1  close_2  max_30  min_30 remark\n",
       "date                                                      \n",
       "2022-01-25   3.66     3.72     3.68    4.10    3.66   历史低点\n",
       "2022-04-28   3.45     3.61     3.57    5.15    3.45   历史低点\n",
       "2022-08-09   5.49     5.71     5.70    7.34    5.49   历史低点\n",
       "2022-10-10   5.71     5.88     6.19    9.00    5.71   历史低点\n",
       "2022-10-24   5.57     6.13     6.16    9.00    5.57   历史低点"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ddd = df_last[(df_last['close'] < df_last['close_1']) & (df_last['close'] <= df_last['close_2']) & (\n",
    "            df_last['close'] == df_last['min_30'])]\n",
    "ddd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_last['ma_10'] = df_last['close'].rolling(5).mean()\n",
    "df_last['ma_20'] = df_last['close'].rolling(10).mean()\n",
    "df_last.loc[\n",
    "    (df_last['ma_10'] >= df_last['ma_20']) & (df_last['ma_10'].shift(1) < df_last['ma_20'].shift(1)), 'signal'] = '1'\n",
    "df_last.loc[\n",
    "    (df_last['ma_10'] <= df_last['ma_20']) & (df_last['ma_10'].shift(1) > df_last['ma_20'].shift(1)), 'signal'] = '-1'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>close_1</th>\n",
       "      <th>close_2</th>\n",
       "      <th>max_30</th>\n",
       "      <th>min_30</th>\n",
       "      <th>remark</th>\n",
       "      <th>ma_10</th>\n",
       "      <th>ma_20</th>\n",
       "      <th>signal</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-01-04</th>\n",
       "      <td>4.10</td>\n",
       "      <td>4.10</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-05</th>\n",
       "      <td>4.10</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.01</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>历史高点</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-06</th>\n",
       "      <td>4.05</td>\n",
       "      <td>4.01</td>\n",
       "      <td>4.03</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-07</th>\n",
       "      <td>4.01</td>\n",
       "      <td>4.03</td>\n",
       "      <td>3.97</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-10</th>\n",
       "      <td>4.03</td>\n",
       "      <td>3.97</td>\n",
       "      <td>4.04</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.058</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-11</th>\n",
       "      <td>3.97</td>\n",
       "      <td>4.04</td>\n",
       "      <td>4.03</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.032</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-12</th>\n",
       "      <td>4.04</td>\n",
       "      <td>4.03</td>\n",
       "      <td>3.95</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.020</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-13</th>\n",
       "      <td>4.03</td>\n",
       "      <td>3.95</td>\n",
       "      <td>4.02</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.016</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-14</th>\n",
       "      <td>3.95</td>\n",
       "      <td>4.02</td>\n",
       "      <td>3.95</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.004</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-17</th>\n",
       "      <td>4.02</td>\n",
       "      <td>3.95</td>\n",
       "      <td>4.06</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.002</td>\n",
       "      <td>4.030</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-18</th>\n",
       "      <td>3.95</td>\n",
       "      <td>4.06</td>\n",
       "      <td>3.94</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.998</td>\n",
       "      <td>4.015</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-19</th>\n",
       "      <td>4.06</td>\n",
       "      <td>3.94</td>\n",
       "      <td>3.89</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.002</td>\n",
       "      <td>4.011</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-20</th>\n",
       "      <td>3.94</td>\n",
       "      <td>3.89</td>\n",
       "      <td>3.86</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.984</td>\n",
       "      <td>4.000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-21</th>\n",
       "      <td>3.89</td>\n",
       "      <td>3.86</td>\n",
       "      <td>3.66</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.972</td>\n",
       "      <td>3.988</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-24</th>\n",
       "      <td>3.86</td>\n",
       "      <td>3.66</td>\n",
       "      <td>3.72</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.940</td>\n",
       "      <td>3.971</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-25</th>\n",
       "      <td>3.66</td>\n",
       "      <td>3.72</td>\n",
       "      <td>3.68</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>历史低点</td>\n",
       "      <td>3.882</td>\n",
       "      <td>3.940</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-26</th>\n",
       "      <td>3.72</td>\n",
       "      <td>3.68</td>\n",
       "      <td>3.80</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.814</td>\n",
       "      <td>3.908</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-27</th>\n",
       "      <td>3.68</td>\n",
       "      <td>3.80</td>\n",
       "      <td>3.83</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.762</td>\n",
       "      <td>3.873</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-28</th>\n",
       "      <td>3.80</td>\n",
       "      <td>3.83</td>\n",
       "      <td>3.93</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.744</td>\n",
       "      <td>3.858</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-07</th>\n",
       "      <td>3.83</td>\n",
       "      <td>3.93</td>\n",
       "      <td>3.91</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.738</td>\n",
       "      <td>3.839</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-08</th>\n",
       "      <td>3.93</td>\n",
       "      <td>3.91</td>\n",
       "      <td>3.89</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.792</td>\n",
       "      <td>3.837</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-09</th>\n",
       "      <td>3.91</td>\n",
       "      <td>3.89</td>\n",
       "      <td>3.87</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.830</td>\n",
       "      <td>3.822</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-10</th>\n",
       "      <td>3.89</td>\n",
       "      <td>3.87</td>\n",
       "      <td>3.84</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.872</td>\n",
       "      <td>3.817</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-11</th>\n",
       "      <td>3.87</td>\n",
       "      <td>3.84</td>\n",
       "      <td>3.83</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.886</td>\n",
       "      <td>3.815</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-14</th>\n",
       "      <td>3.84</td>\n",
       "      <td>3.83</td>\n",
       "      <td>3.85</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.888</td>\n",
       "      <td>3.813</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-15</th>\n",
       "      <td>3.83</td>\n",
       "      <td>3.85</td>\n",
       "      <td>3.84</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.868</td>\n",
       "      <td>3.830</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-16</th>\n",
       "      <td>3.85</td>\n",
       "      <td>3.84</td>\n",
       "      <td>3.88</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.856</td>\n",
       "      <td>3.843</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-17</th>\n",
       "      <td>3.84</td>\n",
       "      <td>3.88</td>\n",
       "      <td>4.02</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.846</td>\n",
       "      <td>3.859</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-18</th>\n",
       "      <td>3.88</td>\n",
       "      <td>4.02</td>\n",
       "      <td>4.18</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.848</td>\n",
       "      <td>3.867</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-21</th>\n",
       "      <td>4.02</td>\n",
       "      <td>4.18</td>\n",
       "      <td>4.22</td>\n",
       "      <td>4.10</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.884</td>\n",
       "      <td>3.886</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-22</th>\n",
       "      <td>4.18</td>\n",
       "      <td>4.22</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.18</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.954</td>\n",
       "      <td>3.911</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-23</th>\n",
       "      <td>4.22</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.10</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>历史高点</td>\n",
       "      <td>4.028</td>\n",
       "      <td>3.942</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-24</th>\n",
       "      <td>4.05</td>\n",
       "      <td>4.10</td>\n",
       "      <td>4.06</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.070</td>\n",
       "      <td>3.958</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-25</th>\n",
       "      <td>4.10</td>\n",
       "      <td>4.06</td>\n",
       "      <td>4.06</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.114</td>\n",
       "      <td>3.981</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>4.06</td>\n",
       "      <td>4.06</td>\n",
       "      <td>4.12</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.122</td>\n",
       "      <td>4.003</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-01</th>\n",
       "      <td>4.06</td>\n",
       "      <td>4.12</td>\n",
       "      <td>4.11</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.098</td>\n",
       "      <td>4.026</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-02</th>\n",
       "      <td>4.12</td>\n",
       "      <td>4.11</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.078</td>\n",
       "      <td>4.053</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-03</th>\n",
       "      <td>4.11</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.07</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.090</td>\n",
       "      <td>4.080</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-04</th>\n",
       "      <td>4.05</td>\n",
       "      <td>4.07</td>\n",
       "      <td>4.05</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.080</td>\n",
       "      <td>4.097</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-07</th>\n",
       "      <td>4.07</td>\n",
       "      <td>4.05</td>\n",
       "      <td>3.96</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.082</td>\n",
       "      <td>4.102</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-08</th>\n",
       "      <td>4.05</td>\n",
       "      <td>3.96</td>\n",
       "      <td>3.98</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.080</td>\n",
       "      <td>4.089</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-09</th>\n",
       "      <td>3.96</td>\n",
       "      <td>3.98</td>\n",
       "      <td>4.11</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.048</td>\n",
       "      <td>4.063</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-10</th>\n",
       "      <td>3.98</td>\n",
       "      <td>4.11</td>\n",
       "      <td>4.52</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.022</td>\n",
       "      <td>4.056</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-11</th>\n",
       "      <td>4.11</td>\n",
       "      <td>4.52</td>\n",
       "      <td>4.26</td>\n",
       "      <td>4.22</td>\n",
       "      <td>3.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.034</td>\n",
       "      <td>4.057</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-14</th>\n",
       "      <td>4.52</td>\n",
       "      <td>4.26</td>\n",
       "      <td>4.43</td>\n",
       "      <td>4.52</td>\n",
       "      <td>3.66</td>\n",
       "      <td>历史高点</td>\n",
       "      <td>4.124</td>\n",
       "      <td>4.103</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-15</th>\n",
       "      <td>4.26</td>\n",
       "      <td>4.43</td>\n",
       "      <td>4.61</td>\n",
       "      <td>4.52</td>\n",
       "      <td>3.68</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.166</td>\n",
       "      <td>4.123</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-16</th>\n",
       "      <td>4.43</td>\n",
       "      <td>4.61</td>\n",
       "      <td>4.68</td>\n",
       "      <td>4.52</td>\n",
       "      <td>3.68</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.260</td>\n",
       "      <td>4.154</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-17</th>\n",
       "      <td>4.61</td>\n",
       "      <td>4.68</td>\n",
       "      <td>5.15</td>\n",
       "      <td>4.61</td>\n",
       "      <td>3.80</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.386</td>\n",
       "      <td>4.204</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-18</th>\n",
       "      <td>4.68</td>\n",
       "      <td>5.15</td>\n",
       "      <td>5.01</td>\n",
       "      <td>4.68</td>\n",
       "      <td>3.83</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.500</td>\n",
       "      <td>4.267</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-21</th>\n",
       "      <td>5.15</td>\n",
       "      <td>5.01</td>\n",
       "      <td>4.99</td>\n",
       "      <td>5.15</td>\n",
       "      <td>3.83</td>\n",
       "      <td>历史高点</td>\n",
       "      <td>4.626</td>\n",
       "      <td>4.375</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            close  close_1  close_2  max_30  min_30 remark  ma_10  ma_20  \\\n",
       "date                                                                       \n",
       "2022-01-04   4.10     4.10     4.05    4.10    3.66    NaN    NaN    NaN   \n",
       "2022-01-05   4.10     4.05     4.01    4.10    3.66   历史高点    NaN    NaN   \n",
       "2022-01-06   4.05     4.01     4.03    4.10    3.66    NaN    NaN    NaN   \n",
       "2022-01-07   4.01     4.03     3.97    4.10    3.66    NaN    NaN    NaN   \n",
       "2022-01-10   4.03     3.97     4.04    4.10    3.66    NaN  4.058    NaN   \n",
       "2022-01-11   3.97     4.04     4.03    4.10    3.66    NaN  4.032    NaN   \n",
       "2022-01-12   4.04     4.03     3.95    4.10    3.66    NaN  4.020    NaN   \n",
       "2022-01-13   4.03     3.95     4.02    4.10    3.66    NaN  4.016    NaN   \n",
       "2022-01-14   3.95     4.02     3.95    4.10    3.66    NaN  4.004    NaN   \n",
       "2022-01-17   4.02     3.95     4.06    4.10    3.66    NaN  4.002  4.030   \n",
       "2022-01-18   3.95     4.06     3.94    4.10    3.66    NaN  3.998  4.015   \n",
       "2022-01-19   4.06     3.94     3.89    4.10    3.66    NaN  4.002  4.011   \n",
       "2022-01-20   3.94     3.89     3.86    4.10    3.66    NaN  3.984  4.000   \n",
       "2022-01-21   3.89     3.86     3.66    4.10    3.66    NaN  3.972  3.988   \n",
       "2022-01-24   3.86     3.66     3.72    4.10    3.66    NaN  3.940  3.971   \n",
       "2022-01-25   3.66     3.72     3.68    4.10    3.66   历史低点  3.882  3.940   \n",
       "2022-01-26   3.72     3.68     3.80    4.10    3.66    NaN  3.814  3.908   \n",
       "2022-01-27   3.68     3.80     3.83    4.10    3.66    NaN  3.762  3.873   \n",
       "2022-01-28   3.80     3.83     3.93    4.10    3.66    NaN  3.744  3.858   \n",
       "2022-02-07   3.83     3.93     3.91    4.10    3.66    NaN  3.738  3.839   \n",
       "2022-02-08   3.93     3.91     3.89    4.10    3.66    NaN  3.792  3.837   \n",
       "2022-02-09   3.91     3.89     3.87    4.10    3.66    NaN  3.830  3.822   \n",
       "2022-02-10   3.89     3.87     3.84    4.10    3.66    NaN  3.872  3.817   \n",
       "2022-02-11   3.87     3.84     3.83    4.10    3.66    NaN  3.886  3.815   \n",
       "2022-02-14   3.84     3.83     3.85    4.10    3.66    NaN  3.888  3.813   \n",
       "2022-02-15   3.83     3.85     3.84    4.10    3.66    NaN  3.868  3.830   \n",
       "2022-02-16   3.85     3.84     3.88    4.10    3.66    NaN  3.856  3.843   \n",
       "2022-02-17   3.84     3.88     4.02    4.10    3.66    NaN  3.846  3.859   \n",
       "2022-02-18   3.88     4.02     4.18    4.10    3.66    NaN  3.848  3.867   \n",
       "2022-02-21   4.02     4.18     4.22    4.10    3.66    NaN  3.884  3.886   \n",
       "2022-02-22   4.18     4.22     4.05    4.18    3.66    NaN  3.954  3.911   \n",
       "2022-02-23   4.22     4.05     4.10    4.22    3.66   历史高点  4.028  3.942   \n",
       "2022-02-24   4.05     4.10     4.06    4.22    3.66    NaN  4.070  3.958   \n",
       "2022-02-25   4.10     4.06     4.06    4.22    3.66    NaN  4.114  3.981   \n",
       "2022-02-28   4.06     4.06     4.12    4.22    3.66    NaN  4.122  4.003   \n",
       "2022-03-01   4.06     4.12     4.11    4.22    3.66    NaN  4.098  4.026   \n",
       "2022-03-02   4.12     4.11     4.05    4.22    3.66    NaN  4.078  4.053   \n",
       "2022-03-03   4.11     4.05     4.07    4.22    3.66    NaN  4.090  4.080   \n",
       "2022-03-04   4.05     4.07     4.05    4.22    3.66    NaN  4.080  4.097   \n",
       "2022-03-07   4.07     4.05     3.96    4.22    3.66    NaN  4.082  4.102   \n",
       "2022-03-08   4.05     3.96     3.98    4.22    3.66    NaN  4.080  4.089   \n",
       "2022-03-09   3.96     3.98     4.11    4.22    3.66    NaN  4.048  4.063   \n",
       "2022-03-10   3.98     4.11     4.52    4.22    3.66    NaN  4.022  4.056   \n",
       "2022-03-11   4.11     4.52     4.26    4.22    3.66    NaN  4.034  4.057   \n",
       "2022-03-14   4.52     4.26     4.43    4.52    3.66   历史高点  4.124  4.103   \n",
       "2022-03-15   4.26     4.43     4.61    4.52    3.68    NaN  4.166  4.123   \n",
       "2022-03-16   4.43     4.61     4.68    4.52    3.68    NaN  4.260  4.154   \n",
       "2022-03-17   4.61     4.68     5.15    4.61    3.80    NaN  4.386  4.204   \n",
       "2022-03-18   4.68     5.15     5.01    4.68    3.83    NaN  4.500  4.267   \n",
       "2022-03-21   5.15     5.01     4.99    5.15    3.83   历史高点  4.626  4.375   \n",
       "\n",
       "           signal  \n",
       "date               \n",
       "2022-01-04    NaN  \n",
       "2022-01-05    NaN  \n",
       "2022-01-06    NaN  \n",
       "2022-01-07    NaN  \n",
       "2022-01-10    NaN  \n",
       "2022-01-11    NaN  \n",
       "2022-01-12    NaN  \n",
       "2022-01-13    NaN  \n",
       "2022-01-14    NaN  \n",
       "2022-01-17    NaN  \n",
       "2022-01-18    NaN  \n",
       "2022-01-19    NaN  \n",
       "2022-01-20    NaN  \n",
       "2022-01-21    NaN  \n",
       "2022-01-24    NaN  \n",
       "2022-01-25    NaN  \n",
       "2022-01-26    NaN  \n",
       "2022-01-27    NaN  \n",
       "2022-01-28    NaN  \n",
       "2022-02-07    NaN  \n",
       "2022-02-08    NaN  \n",
       "2022-02-09      1  \n",
       "2022-02-10    NaN  \n",
       "2022-02-11    NaN  \n",
       "2022-02-14    NaN  \n",
       "2022-02-15    NaN  \n",
       "2022-02-16    NaN  \n",
       "2022-02-17     -1  \n",
       "2022-02-18    NaN  \n",
       "2022-02-21    NaN  \n",
       "2022-02-22      1  \n",
       "2022-02-23    NaN  \n",
       "2022-02-24    NaN  \n",
       "2022-02-25    NaN  \n",
       "2022-02-28    NaN  \n",
       "2022-03-01    NaN  \n",
       "2022-03-02    NaN  \n",
       "2022-03-03    NaN  \n",
       "2022-03-04     -1  \n",
       "2022-03-07    NaN  \n",
       "2022-03-08    NaN  \n",
       "2022-03-09    NaN  \n",
       "2022-03-10    NaN  \n",
       "2022-03-11    NaN  \n",
       "2022-03-14      1  \n",
       "2022-03-15    NaN  \n",
       "2022-03-16    NaN  \n",
       "2022-03-17    NaN  \n",
       "2022-03-18    NaN  \n",
       "2022-03-21    NaN  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_last.head(50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_last.fillna(value='0', inplace=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>amount</th>\n",
       "      <th>振幅</th>\n",
       "      <th>pctChg</th>\n",
       "      <th>涨跌</th>\n",
       "      <th>turn</th>\n",
       "      <th>ranking</th>\n",
       "      <th>score</th>\n",
       "      <th>压力位</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-09-01</th>\n",
       "      <td>5.82</td>\n",
       "      <td>5.75</td>\n",
       "      <td>5.89</td>\n",
       "      <td>5.70</td>\n",
       "      <td>218770</td>\n",
       "      <td>1.264017e+08</td>\n",
       "      <td>3.27</td>\n",
       "      <td>-1.03</td>\n",
       "      <td>-0.06</td>\n",
       "      <td>2.98</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-02</th>\n",
       "      <td>5.74</td>\n",
       "      <td>6.21</td>\n",
       "      <td>6.33</td>\n",
       "      <td>5.70</td>\n",
       "      <td>468662</td>\n",
       "      <td>2.829114e+08</td>\n",
       "      <td>10.96</td>\n",
       "      <td>8.00</td>\n",
       "      <td>0.46</td>\n",
       "      <td>6.39</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-05</th>\n",
       "      <td>6.22</td>\n",
       "      <td>6.64</td>\n",
       "      <td>6.78</td>\n",
       "      <td>6.09</td>\n",
       "      <td>990301</td>\n",
       "      <td>6.395433e+08</td>\n",
       "      <td>11.11</td>\n",
       "      <td>6.92</td>\n",
       "      <td>0.43</td>\n",
       "      <td>13.50</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-06</th>\n",
       "      <td>6.69</td>\n",
       "      <td>7.02</td>\n",
       "      <td>7.25</td>\n",
       "      <td>6.51</td>\n",
       "      <td>1043010</td>\n",
       "      <td>7.109852e+08</td>\n",
       "      <td>11.14</td>\n",
       "      <td>5.72</td>\n",
       "      <td>0.38</td>\n",
       "      <td>14.22</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-07</th>\n",
       "      <td>7.51</td>\n",
       "      <td>7.72</td>\n",
       "      <td>7.72</td>\n",
       "      <td>6.91</td>\n",
       "      <td>1225546</td>\n",
       "      <td>9.178049e+08</td>\n",
       "      <td>11.54</td>\n",
       "      <td>9.97</td>\n",
       "      <td>0.70</td>\n",
       "      <td>16.71</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            open  close  high   low   volume        amount     振幅  pctChg  \\\n",
       "date                                                                        \n",
       "2022-09-01  5.82   5.75  5.89  5.70   218770  1.264017e+08   3.27   -1.03   \n",
       "2022-09-02  5.74   6.21  6.33  5.70   468662  2.829114e+08  10.96    8.00   \n",
       "2022-09-05  6.22   6.64  6.78  6.09   990301  6.395433e+08  11.11    6.92   \n",
       "2022-09-06  6.69   7.02  7.25  6.51  1043010  7.109852e+08  11.14    5.72   \n",
       "2022-09-07  7.51   7.72  7.72  6.91  1225546  9.178049e+08  11.54    9.97   \n",
       "\n",
       "              涨跌   turn  ranking  score  压力位  \n",
       "date                                          \n",
       "2022-09-01 -0.06   2.98      NaN    NaN  NaN  \n",
       "2022-09-02  0.46   6.39      NaN    NaN  NaN  \n",
       "2022-09-05  0.43  13.50      NaN    NaN  NaN  \n",
       "2022-09-06  0.38  14.22      NaN    NaN  NaN  \n",
       "2022-09-07  0.70  16.71      NaN    NaN  NaN  "
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_last.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd_data = pd.read_csv(r'../service/requests/datas/000868.csv',parse_dates=['date'],index_col='date')\n",
    "\n",
    "df_last = pd_data[['open', 'close', 'high', 'low', 'volume', 'pctChg', 'turn']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "pycharm": {
     "is_executing": true,
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "period = 30\n",
    "# df_last=pd_data\n",
    "df_last['ranking'] = df_last['volume'].rolling(period).rank()\n",
    "df_last['score'] = df_last['ranking'].map(lambda x: 2 * (x - 1) / period - 1)\n",
    "# df_last['2022-09']\n",
    "# dd=df_last[df_last['score'] > 0.8]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "pycharm": {
     "is_executing": true
    }
   },
   "outputs": [],
   "source": [
    "# 放量上涨\n",
    "df_last.loc[(df_last['pctChg']>6) & (df_last['score']>0.8),'压力位']=1\n",
    "# 放量下跌\n",
    "df_last.loc[(df_last['pctChg']<-5) & (df_last['score']>0.8),'压力位']=-1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "pycharm": {
     "is_executing": true
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>pctChg</th>\n",
       "      <th>turn</th>\n",
       "      <th>ranking</th>\n",
       "      <th>score</th>\n",
       "      <th>压力位</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-08-01</th>\n",
       "      <td>5.97</td>\n",
       "      <td>6.22</td>\n",
       "      <td>6.28</td>\n",
       "      <td>5.82</td>\n",
       "      <td>734597</td>\n",
       "      <td>2.30</td>\n",
       "      <td>10.02</td>\n",
       "      <td>13.0</td>\n",
       "      <td>-0.200000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-02</th>\n",
       "      <td>6.03</td>\n",
       "      <td>5.75</td>\n",
       "      <td>6.07</td>\n",
       "      <td>5.73</td>\n",
       "      <td>594189</td>\n",
       "      <td>-7.56</td>\n",
       "      <td>8.10</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-03</th>\n",
       "      <td>5.73</td>\n",
       "      <td>5.86</td>\n",
       "      <td>6.24</td>\n",
       "      <td>5.73</td>\n",
       "      <td>619598</td>\n",
       "      <td>1.91</td>\n",
       "      <td>8.45</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-04</th>\n",
       "      <td>5.75</td>\n",
       "      <td>5.68</td>\n",
       "      <td>5.79</td>\n",
       "      <td>5.48</td>\n",
       "      <td>523566</td>\n",
       "      <td>-3.07</td>\n",
       "      <td>7.14</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-0.866667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-05</th>\n",
       "      <td>5.60</td>\n",
       "      <td>5.52</td>\n",
       "      <td>5.69</td>\n",
       "      <td>5.40</td>\n",
       "      <td>349961</td>\n",
       "      <td>-2.82</td>\n",
       "      <td>4.77</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-08</th>\n",
       "      <td>5.50</td>\n",
       "      <td>5.54</td>\n",
       "      <td>5.60</td>\n",
       "      <td>5.36</td>\n",
       "      <td>236094</td>\n",
       "      <td>0.36</td>\n",
       "      <td>3.22</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-09</th>\n",
       "      <td>5.55</td>\n",
       "      <td>5.49</td>\n",
       "      <td>5.70</td>\n",
       "      <td>5.48</td>\n",
       "      <td>272570</td>\n",
       "      <td>-0.90</td>\n",
       "      <td>3.72</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-0.933333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-10</th>\n",
       "      <td>5.44</td>\n",
       "      <td>5.71</td>\n",
       "      <td>5.90</td>\n",
       "      <td>5.44</td>\n",
       "      <td>581752</td>\n",
       "      <td>4.01</td>\n",
       "      <td>7.93</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-0.533333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-11</th>\n",
       "      <td>5.61</td>\n",
       "      <td>5.70</td>\n",
       "      <td>5.75</td>\n",
       "      <td>5.54</td>\n",
       "      <td>389010</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>5.30</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-12</th>\n",
       "      <td>5.68</td>\n",
       "      <td>5.63</td>\n",
       "      <td>5.72</td>\n",
       "      <td>5.63</td>\n",
       "      <td>213493</td>\n",
       "      <td>-1.23</td>\n",
       "      <td>2.91</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-15</th>\n",
       "      <td>5.66</td>\n",
       "      <td>5.70</td>\n",
       "      <td>5.90</td>\n",
       "      <td>5.60</td>\n",
       "      <td>314647</td>\n",
       "      <td>1.24</td>\n",
       "      <td>4.29</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-0.800000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-16</th>\n",
       "      <td>5.91</td>\n",
       "      <td>6.27</td>\n",
       "      <td>6.27</td>\n",
       "      <td>5.91</td>\n",
       "      <td>730391</td>\n",
       "      <td>10.00</td>\n",
       "      <td>9.96</td>\n",
       "      <td>18.0</td>\n",
       "      <td>0.133333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-17</th>\n",
       "      <td>6.08</td>\n",
       "      <td>6.32</td>\n",
       "      <td>6.65</td>\n",
       "      <td>6.00</td>\n",
       "      <td>1199262</td>\n",
       "      <td>0.80</td>\n",
       "      <td>16.35</td>\n",
       "      <td>29.0</td>\n",
       "      <td>0.866667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-18</th>\n",
       "      <td>6.36</td>\n",
       "      <td>6.16</td>\n",
       "      <td>6.42</td>\n",
       "      <td>6.14</td>\n",
       "      <td>592063</td>\n",
       "      <td>-2.53</td>\n",
       "      <td>8.07</td>\n",
       "      <td>12.0</td>\n",
       "      <td>-0.266667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-19</th>\n",
       "      <td>6.18</td>\n",
       "      <td>5.93</td>\n",
       "      <td>6.21</td>\n",
       "      <td>5.92</td>\n",
       "      <td>434246</td>\n",
       "      <td>-3.73</td>\n",
       "      <td>5.92</td>\n",
       "      <td>9.0</td>\n",
       "      <td>-0.466667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-22</th>\n",
       "      <td>5.93</td>\n",
       "      <td>6.25</td>\n",
       "      <td>6.50</td>\n",
       "      <td>5.90</td>\n",
       "      <td>685255</td>\n",
       "      <td>5.40</td>\n",
       "      <td>9.34</td>\n",
       "      <td>18.0</td>\n",
       "      <td>0.133333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-23</th>\n",
       "      <td>6.10</td>\n",
       "      <td>6.06</td>\n",
       "      <td>6.17</td>\n",
       "      <td>5.96</td>\n",
       "      <td>454374</td>\n",
       "      <td>-3.04</td>\n",
       "      <td>6.20</td>\n",
       "      <td>10.0</td>\n",
       "      <td>-0.400000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-24</th>\n",
       "      <td>6.00</td>\n",
       "      <td>5.71</td>\n",
       "      <td>6.06</td>\n",
       "      <td>5.68</td>\n",
       "      <td>496000</td>\n",
       "      <td>-5.78</td>\n",
       "      <td>6.76</td>\n",
       "      <td>11.0</td>\n",
       "      <td>-0.333333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-25</th>\n",
       "      <td>5.73</td>\n",
       "      <td>5.77</td>\n",
       "      <td>5.86</td>\n",
       "      <td>5.60</td>\n",
       "      <td>309237</td>\n",
       "      <td>1.05</td>\n",
       "      <td>4.22</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-0.800000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-26</th>\n",
       "      <td>5.78</td>\n",
       "      <td>5.81</td>\n",
       "      <td>5.95</td>\n",
       "      <td>5.72</td>\n",
       "      <td>293653</td>\n",
       "      <td>0.69</td>\n",
       "      <td>4.00</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-0.800000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-29</th>\n",
       "      <td>5.72</td>\n",
       "      <td>6.13</td>\n",
       "      <td>6.25</td>\n",
       "      <td>5.64</td>\n",
       "      <td>554625</td>\n",
       "      <td>5.51</td>\n",
       "      <td>7.56</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-30</th>\n",
       "      <td>6.17</td>\n",
       "      <td>6.02</td>\n",
       "      <td>6.23</td>\n",
       "      <td>5.93</td>\n",
       "      <td>400073</td>\n",
       "      <td>-1.79</td>\n",
       "      <td>5.46</td>\n",
       "      <td>11.0</td>\n",
       "      <td>-0.333333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>6.02</td>\n",
       "      <td>5.81</td>\n",
       "      <td>6.03</td>\n",
       "      <td>5.77</td>\n",
       "      <td>330323</td>\n",
       "      <td>-3.49</td>\n",
       "      <td>4.50</td>\n",
       "      <td>7.0</td>\n",
       "      <td>-0.600000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-01</th>\n",
       "      <td>5.82</td>\n",
       "      <td>5.75</td>\n",
       "      <td>5.89</td>\n",
       "      <td>5.70</td>\n",
       "      <td>218770</td>\n",
       "      <td>-1.03</td>\n",
       "      <td>2.98</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-0.933333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-02</th>\n",
       "      <td>5.74</td>\n",
       "      <td>6.21</td>\n",
       "      <td>6.33</td>\n",
       "      <td>5.70</td>\n",
       "      <td>468662</td>\n",
       "      <td>8.00</td>\n",
       "      <td>6.39</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-05</th>\n",
       "      <td>6.22</td>\n",
       "      <td>6.64</td>\n",
       "      <td>6.78</td>\n",
       "      <td>6.09</td>\n",
       "      <td>990301</td>\n",
       "      <td>6.92</td>\n",
       "      <td>13.50</td>\n",
       "      <td>29.0</td>\n",
       "      <td>0.866667</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-06</th>\n",
       "      <td>6.69</td>\n",
       "      <td>7.02</td>\n",
       "      <td>7.25</td>\n",
       "      <td>6.51</td>\n",
       "      <td>1043010</td>\n",
       "      <td>5.72</td>\n",
       "      <td>14.22</td>\n",
       "      <td>29.0</td>\n",
       "      <td>0.866667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-07</th>\n",
       "      <td>7.51</td>\n",
       "      <td>7.72</td>\n",
       "      <td>7.72</td>\n",
       "      <td>6.91</td>\n",
       "      <td>1225546</td>\n",
       "      <td>9.97</td>\n",
       "      <td>16.71</td>\n",
       "      <td>30.0</td>\n",
       "      <td>0.933333</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-08</th>\n",
       "      <td>7.70</td>\n",
       "      <td>8.49</td>\n",
       "      <td>8.49</td>\n",
       "      <td>7.51</td>\n",
       "      <td>840741</td>\n",
       "      <td>9.97</td>\n",
       "      <td>11.46</td>\n",
       "      <td>26.0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-09</th>\n",
       "      <td>8.77</td>\n",
       "      <td>7.69</td>\n",
       "      <td>8.95</td>\n",
       "      <td>7.64</td>\n",
       "      <td>1764945</td>\n",
       "      <td>-9.42</td>\n",
       "      <td>24.07</td>\n",
       "      <td>30.0</td>\n",
       "      <td>0.933333</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-13</th>\n",
       "      <td>7.57</td>\n",
       "      <td>8.46</td>\n",
       "      <td>8.46</td>\n",
       "      <td>7.23</td>\n",
       "      <td>1683356</td>\n",
       "      <td>10.01</td>\n",
       "      <td>22.95</td>\n",
       "      <td>29.0</td>\n",
       "      <td>0.866667</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-14</th>\n",
       "      <td>8.08</td>\n",
       "      <td>9.00</td>\n",
       "      <td>9.19</td>\n",
       "      <td>7.92</td>\n",
       "      <td>1827500</td>\n",
       "      <td>6.38</td>\n",
       "      <td>24.92</td>\n",
       "      <td>30.0</td>\n",
       "      <td>0.933333</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-15</th>\n",
       "      <td>8.90</td>\n",
       "      <td>8.96</td>\n",
       "      <td>9.18</td>\n",
       "      <td>8.38</td>\n",
       "      <td>1436811</td>\n",
       "      <td>-0.44</td>\n",
       "      <td>19.59</td>\n",
       "      <td>27.0</td>\n",
       "      <td>0.733333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-16</th>\n",
       "      <td>8.66</td>\n",
       "      <td>8.14</td>\n",
       "      <td>8.77</td>\n",
       "      <td>8.08</td>\n",
       "      <td>1024190</td>\n",
       "      <td>-9.15</td>\n",
       "      <td>13.97</td>\n",
       "      <td>23.0</td>\n",
       "      <td>0.466667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-19</th>\n",
       "      <td>8.24</td>\n",
       "      <td>8.50</td>\n",
       "      <td>8.78</td>\n",
       "      <td>8.20</td>\n",
       "      <td>1103484</td>\n",
       "      <td>4.42</td>\n",
       "      <td>15.05</td>\n",
       "      <td>24.0</td>\n",
       "      <td>0.533333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-20</th>\n",
       "      <td>8.59</td>\n",
       "      <td>7.66</td>\n",
       "      <td>9.20</td>\n",
       "      <td>7.66</td>\n",
       "      <td>1736789</td>\n",
       "      <td>-9.88</td>\n",
       "      <td>23.68</td>\n",
       "      <td>28.0</td>\n",
       "      <td>0.800000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-21</th>\n",
       "      <td>7.60</td>\n",
       "      <td>7.95</td>\n",
       "      <td>8.16</td>\n",
       "      <td>7.59</td>\n",
       "      <td>1420695</td>\n",
       "      <td>3.79</td>\n",
       "      <td>19.37</td>\n",
       "      <td>25.0</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-22</th>\n",
       "      <td>8.00</td>\n",
       "      <td>7.89</td>\n",
       "      <td>8.10</td>\n",
       "      <td>7.41</td>\n",
       "      <td>1126408</td>\n",
       "      <td>-0.75</td>\n",
       "      <td>15.36</td>\n",
       "      <td>22.0</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-23</th>\n",
       "      <td>7.88</td>\n",
       "      <td>7.46</td>\n",
       "      <td>7.88</td>\n",
       "      <td>7.26</td>\n",
       "      <td>916134</td>\n",
       "      <td>-5.45</td>\n",
       "      <td>12.49</td>\n",
       "      <td>17.0</td>\n",
       "      <td>0.066667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-26</th>\n",
       "      <td>7.41</td>\n",
       "      <td>7.64</td>\n",
       "      <td>7.82</td>\n",
       "      <td>7.28</td>\n",
       "      <td>770011</td>\n",
       "      <td>2.41</td>\n",
       "      <td>10.50</td>\n",
       "      <td>15.0</td>\n",
       "      <td>-0.066667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-27</th>\n",
       "      <td>7.75</td>\n",
       "      <td>7.73</td>\n",
       "      <td>7.77</td>\n",
       "      <td>7.43</td>\n",
       "      <td>721787</td>\n",
       "      <td>1.18</td>\n",
       "      <td>9.84</td>\n",
       "      <td>13.0</td>\n",
       "      <td>-0.200000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-28</th>\n",
       "      <td>7.60</td>\n",
       "      <td>6.96</td>\n",
       "      <td>7.60</td>\n",
       "      <td>6.96</td>\n",
       "      <td>749002</td>\n",
       "      <td>-9.96</td>\n",
       "      <td>10.21</td>\n",
       "      <td>14.0</td>\n",
       "      <td>-0.133333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-29</th>\n",
       "      <td>6.85</td>\n",
       "      <td>6.41</td>\n",
       "      <td>6.94</td>\n",
       "      <td>6.30</td>\n",
       "      <td>877578</td>\n",
       "      <td>-7.90</td>\n",
       "      <td>11.97</td>\n",
       "      <td>17.0</td>\n",
       "      <td>0.066667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>6.39</td>\n",
       "      <td>6.02</td>\n",
       "      <td>6.49</td>\n",
       "      <td>5.95</td>\n",
       "      <td>760381</td>\n",
       "      <td>-6.08</td>\n",
       "      <td>10.37</td>\n",
       "      <td>14.0</td>\n",
       "      <td>-0.133333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-10</th>\n",
       "      <td>5.97</td>\n",
       "      <td>5.71</td>\n",
       "      <td>6.01</td>\n",
       "      <td>5.68</td>\n",
       "      <td>468387</td>\n",
       "      <td>-5.15</td>\n",
       "      <td>6.39</td>\n",
       "      <td>7.0</td>\n",
       "      <td>-0.600000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-11</th>\n",
       "      <td>5.73</td>\n",
       "      <td>5.88</td>\n",
       "      <td>5.98</td>\n",
       "      <td>5.64</td>\n",
       "      <td>538356</td>\n",
       "      <td>2.98</td>\n",
       "      <td>7.34</td>\n",
       "      <td>10.0</td>\n",
       "      <td>-0.400000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-12</th>\n",
       "      <td>5.86</td>\n",
       "      <td>6.19</td>\n",
       "      <td>6.30</td>\n",
       "      <td>5.75</td>\n",
       "      <td>704258</td>\n",
       "      <td>5.27</td>\n",
       "      <td>9.60</td>\n",
       "      <td>11.0</td>\n",
       "      <td>-0.333333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-13</th>\n",
       "      <td>6.08</td>\n",
       "      <td>6.04</td>\n",
       "      <td>6.27</td>\n",
       "      <td>6.03</td>\n",
       "      <td>556195</td>\n",
       "      <td>-2.42</td>\n",
       "      <td>7.58</td>\n",
       "      <td>10.0</td>\n",
       "      <td>-0.400000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-14</th>\n",
       "      <td>6.24</td>\n",
       "      <td>6.11</td>\n",
       "      <td>6.31</td>\n",
       "      <td>6.04</td>\n",
       "      <td>626844</td>\n",
       "      <td>1.16</td>\n",
       "      <td>8.55</td>\n",
       "      <td>10.0</td>\n",
       "      <td>-0.400000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-17</th>\n",
       "      <td>6.04</td>\n",
       "      <td>6.09</td>\n",
       "      <td>6.15</td>\n",
       "      <td>5.85</td>\n",
       "      <td>620500</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>8.46</td>\n",
       "      <td>9.0</td>\n",
       "      <td>-0.466667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-18</th>\n",
       "      <td>6.20</td>\n",
       "      <td>6.15</td>\n",
       "      <td>6.46</td>\n",
       "      <td>6.14</td>\n",
       "      <td>1046134</td>\n",
       "      <td>0.99</td>\n",
       "      <td>14.27</td>\n",
       "      <td>21.0</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-19</th>\n",
       "      <td>5.99</td>\n",
       "      <td>6.04</td>\n",
       "      <td>6.34</td>\n",
       "      <td>5.92</td>\n",
       "      <td>821205</td>\n",
       "      <td>-1.79</td>\n",
       "      <td>11.20</td>\n",
       "      <td>14.0</td>\n",
       "      <td>-0.133333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-20</th>\n",
       "      <td>5.93</td>\n",
       "      <td>5.85</td>\n",
       "      <td>6.02</td>\n",
       "      <td>5.75</td>\n",
       "      <td>610472</td>\n",
       "      <td>-3.15</td>\n",
       "      <td>8.32</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-21</th>\n",
       "      <td>5.87</td>\n",
       "      <td>5.66</td>\n",
       "      <td>5.90</td>\n",
       "      <td>5.65</td>\n",
       "      <td>456220</td>\n",
       "      <td>-3.25</td>\n",
       "      <td>6.22</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-24</th>\n",
       "      <td>5.68</td>\n",
       "      <td>5.57</td>\n",
       "      <td>5.78</td>\n",
       "      <td>5.55</td>\n",
       "      <td>349573</td>\n",
       "      <td>-1.59</td>\n",
       "      <td>4.77</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-25</th>\n",
       "      <td>5.55</td>\n",
       "      <td>6.13</td>\n",
       "      <td>6.13</td>\n",
       "      <td>5.43</td>\n",
       "      <td>553659</td>\n",
       "      <td>10.05</td>\n",
       "      <td>7.55</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-0.733333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-26</th>\n",
       "      <td>6.29</td>\n",
       "      <td>6.16</td>\n",
       "      <td>6.55</td>\n",
       "      <td>6.14</td>\n",
       "      <td>1270360</td>\n",
       "      <td>0.49</td>\n",
       "      <td>17.32</td>\n",
       "      <td>24.0</td>\n",
       "      <td>0.533333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-27</th>\n",
       "      <td>6.08</td>\n",
       "      <td>6.10</td>\n",
       "      <td>6.36</td>\n",
       "      <td>6.07</td>\n",
       "      <td>813294</td>\n",
       "      <td>-0.97</td>\n",
       "      <td>11.09</td>\n",
       "      <td>15.0</td>\n",
       "      <td>-0.066667</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-28</th>\n",
       "      <td>6.10</td>\n",
       "      <td>5.75</td>\n",
       "      <td>6.12</td>\n",
       "      <td>5.75</td>\n",
       "      <td>586995</td>\n",
       "      <td>-5.74</td>\n",
       "      <td>8.00</td>\n",
       "      <td>7.0</td>\n",
       "      <td>-0.600000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>5.80</td>\n",
       "      <td>5.79</td>\n",
       "      <td>5.94</td>\n",
       "      <td>5.74</td>\n",
       "      <td>430663</td>\n",
       "      <td>0.70</td>\n",
       "      <td>5.87</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-0.933333</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            open  close  high   low   volume  pctChg   turn  ranking  \\\n",
       "date                                                                   \n",
       "2022-08-01  5.97   6.22  6.28  5.82   734597    2.30  10.02     13.0   \n",
       "2022-08-02  6.03   5.75  6.07  5.73   594189   -7.56   8.10      6.0   \n",
       "2022-08-03  5.73   5.86  6.24  5.73   619598    1.91   8.45      6.0   \n",
       "2022-08-04  5.75   5.68  5.79  5.48   523566   -3.07   7.14      3.0   \n",
       "2022-08-05  5.60   5.52  5.69  5.40   349961   -2.82   4.77      1.0   \n",
       "2022-08-08  5.50   5.54  5.60  5.36   236094    0.36   3.22      1.0   \n",
       "2022-08-09  5.55   5.49  5.70  5.48   272570   -0.90   3.72      2.0   \n",
       "2022-08-10  5.44   5.71  5.90  5.44   581752    4.01   7.93      8.0   \n",
       "2022-08-11  5.61   5.70  5.75  5.54   389010   -0.18   5.30      6.0   \n",
       "2022-08-12  5.68   5.63  5.72  5.63   213493   -1.23   2.91      1.0   \n",
       "2022-08-15  5.66   5.70  5.90  5.60   314647    1.24   4.29      4.0   \n",
       "2022-08-16  5.91   6.27  6.27  5.91   730391   10.00   9.96     18.0   \n",
       "2022-08-17  6.08   6.32  6.65  6.00  1199262    0.80  16.35     29.0   \n",
       "2022-08-18  6.36   6.16  6.42  6.14   592063   -2.53   8.07     12.0   \n",
       "2022-08-19  6.18   5.93  6.21  5.92   434246   -3.73   5.92      9.0   \n",
       "2022-08-22  5.93   6.25  6.50  5.90   685255    5.40   9.34     18.0   \n",
       "2022-08-23  6.10   6.06  6.17  5.96   454374   -3.04   6.20     10.0   \n",
       "2022-08-24  6.00   5.71  6.06  5.68   496000   -5.78   6.76     11.0   \n",
       "2022-08-25  5.73   5.77  5.86  5.60   309237    1.05   4.22      4.0   \n",
       "2022-08-26  5.78   5.81  5.95  5.72   293653    0.69   4.00      4.0   \n",
       "2022-08-29  5.72   6.13  6.25  5.64   554625    5.51   7.56     16.0   \n",
       "2022-08-30  6.17   6.02  6.23  5.93   400073   -1.79   5.46     11.0   \n",
       "2022-08-31  6.02   5.81  6.03  5.77   330323   -3.49   4.50      7.0   \n",
       "2022-09-01  5.82   5.75  5.89  5.70   218770   -1.03   2.98      2.0   \n",
       "2022-09-02  5.74   6.21  6.33  5.70   468662    8.00   6.39     16.0   \n",
       "2022-09-05  6.22   6.64  6.78  6.09   990301    6.92  13.50     29.0   \n",
       "2022-09-06  6.69   7.02  7.25  6.51  1043010    5.72  14.22     29.0   \n",
       "2022-09-07  7.51   7.72  7.72  6.91  1225546    9.97  16.71     30.0   \n",
       "2022-09-08  7.70   8.49  8.49  7.51   840741    9.97  11.46     26.0   \n",
       "2022-09-09  8.77   7.69  8.95  7.64  1764945   -9.42  24.07     30.0   \n",
       "2022-09-13  7.57   8.46  8.46  7.23  1683356   10.01  22.95     29.0   \n",
       "2022-09-14  8.08   9.00  9.19  7.92  1827500    6.38  24.92     30.0   \n",
       "2022-09-15  8.90   8.96  9.18  8.38  1436811   -0.44  19.59     27.0   \n",
       "2022-09-16  8.66   8.14  8.77  8.08  1024190   -9.15  13.97     23.0   \n",
       "2022-09-19  8.24   8.50  8.78  8.20  1103484    4.42  15.05     24.0   \n",
       "2022-09-20  8.59   7.66  9.20  7.66  1736789   -9.88  23.68     28.0   \n",
       "2022-09-21  7.60   7.95  8.16  7.59  1420695    3.79  19.37     25.0   \n",
       "2022-09-22  8.00   7.89  8.10  7.41  1126408   -0.75  15.36     22.0   \n",
       "2022-09-23  7.88   7.46  7.88  7.26   916134   -5.45  12.49     17.0   \n",
       "2022-09-26  7.41   7.64  7.82  7.28   770011    2.41  10.50     15.0   \n",
       "2022-09-27  7.75   7.73  7.77  7.43   721787    1.18   9.84     13.0   \n",
       "2022-09-28  7.60   6.96  7.60  6.96   749002   -9.96  10.21     14.0   \n",
       "2022-09-29  6.85   6.41  6.94  6.30   877578   -7.90  11.97     17.0   \n",
       "2022-09-30  6.39   6.02  6.49  5.95   760381   -6.08  10.37     14.0   \n",
       "2022-10-10  5.97   5.71  6.01  5.68   468387   -5.15   6.39      7.0   \n",
       "2022-10-11  5.73   5.88  5.98  5.64   538356    2.98   7.34     10.0   \n",
       "2022-10-12  5.86   6.19  6.30  5.75   704258    5.27   9.60     11.0   \n",
       "2022-10-13  6.08   6.04  6.27  6.03   556195   -2.42   7.58     10.0   \n",
       "2022-10-14  6.24   6.11  6.31  6.04   626844    1.16   8.55     10.0   \n",
       "2022-10-17  6.04   6.09  6.15  5.85   620500   -0.33   8.46      9.0   \n",
       "2022-10-18  6.20   6.15  6.46  6.14  1046134    0.99  14.27     21.0   \n",
       "2022-10-19  5.99   6.04  6.34  5.92   821205   -1.79  11.20     14.0   \n",
       "2022-10-20  5.93   5.85  6.02  5.75   610472   -3.15   8.32      6.0   \n",
       "2022-10-21  5.87   5.66  5.90  5.65   456220   -3.25   6.22      1.0   \n",
       "2022-10-24  5.68   5.57  5.78  5.55   349573   -1.59   4.77      1.0   \n",
       "2022-10-25  5.55   6.13  6.13  5.43   553659   10.05   7.55      5.0   \n",
       "2022-10-26  6.29   6.16  6.55  6.14  1270360    0.49  17.32     24.0   \n",
       "2022-10-27  6.08   6.10  6.36  6.07   813294   -0.97  11.09     15.0   \n",
       "2022-10-28  6.10   5.75  6.12  5.75   586995   -5.74   8.00      7.0   \n",
       "2022-10-31  5.80   5.79  5.94  5.74   430663    0.70   5.87      2.0   \n",
       "\n",
       "               score  压力位  \n",
       "date                       \n",
       "2022-08-01 -0.200000  NaN  \n",
       "2022-08-02 -0.666667  NaN  \n",
       "2022-08-03 -0.666667  NaN  \n",
       "2022-08-04 -0.866667  NaN  \n",
       "2022-08-05 -1.000000  NaN  \n",
       "2022-08-08 -1.000000  NaN  \n",
       "2022-08-09 -0.933333  NaN  \n",
       "2022-08-10 -0.533333  NaN  \n",
       "2022-08-11 -0.666667  NaN  \n",
       "2022-08-12 -1.000000  NaN  \n",
       "2022-08-15 -0.800000  NaN  \n",
       "2022-08-16  0.133333  NaN  \n",
       "2022-08-17  0.866667  NaN  \n",
       "2022-08-18 -0.266667  NaN  \n",
       "2022-08-19 -0.466667  NaN  \n",
       "2022-08-22  0.133333  NaN  \n",
       "2022-08-23 -0.400000  NaN  \n",
       "2022-08-24 -0.333333  NaN  \n",
       "2022-08-25 -0.800000  NaN  \n",
       "2022-08-26 -0.800000  NaN  \n",
       "2022-08-29  0.000000  NaN  \n",
       "2022-08-30 -0.333333  NaN  \n",
       "2022-08-31 -0.600000  NaN  \n",
       "2022-09-01 -0.933333  NaN  \n",
       "2022-09-02  0.000000  NaN  \n",
       "2022-09-05  0.866667  1.0  \n",
       "2022-09-06  0.866667  NaN  \n",
       "2022-09-07  0.933333  1.0  \n",
       "2022-09-08  0.666667  NaN  \n",
       "2022-09-09  0.933333 -1.0  \n",
       "2022-09-13  0.866667  1.0  \n",
       "2022-09-14  0.933333  1.0  \n",
       "2022-09-15  0.733333  NaN  \n",
       "2022-09-16  0.466667  NaN  \n",
       "2022-09-19  0.533333  NaN  \n",
       "2022-09-20  0.800000  NaN  \n",
       "2022-09-21  0.600000  NaN  \n",
       "2022-09-22  0.400000  NaN  \n",
       "2022-09-23  0.066667  NaN  \n",
       "2022-09-26 -0.066667  NaN  \n",
       "2022-09-27 -0.200000  NaN  \n",
       "2022-09-28 -0.133333  NaN  \n",
       "2022-09-29  0.066667  NaN  \n",
       "2022-09-30 -0.133333  NaN  \n",
       "2022-10-10 -0.600000  NaN  \n",
       "2022-10-11 -0.400000  NaN  \n",
       "2022-10-12 -0.333333  NaN  \n",
       "2022-10-13 -0.400000  NaN  \n",
       "2022-10-14 -0.400000  NaN  \n",
       "2022-10-17 -0.466667  NaN  \n",
       "2022-10-18  0.333333  NaN  \n",
       "2022-10-19 -0.133333  NaN  \n",
       "2022-10-20 -0.666667  NaN  \n",
       "2022-10-21 -1.000000  NaN  \n",
       "2022-10-24 -1.000000  NaN  \n",
       "2022-10-25 -0.733333  NaN  \n",
       "2022-10-26  0.533333  NaN  \n",
       "2022-10-27 -0.066667  NaN  \n",
       "2022-10-28 -0.600000  NaN  \n",
       "2022-10-31 -0.933333  NaN  "
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_last.loc['2022-08':'2022-10']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": true
    }
   },
   "outputs": [],
   "source": [
    "dd=df_last.loc[df_last[\"压力位\"].notnull(),'压力位']\n",
    "\n",
    "totuple = [(l, r) for l, r in zip(dd.index.strftime('%Y-%m-%d'), dd.values)]\n",
    "totuple\n",
    "\n",
    "# https://github.com/matplotlib/mplfinance/blob/master/examples/using_lines.ipynb\n",
    "# https://blog.csdn.net/Shepherdppz/article/details/117575286\n",
    "# https://www.qiniu.com/qfans/qnso-68324852\n",
    "# https://cloud.tencent.com/developer/ask/sof/864310"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": true
    }
   },
   "outputs": [],
   "source": [
    "dd.index.strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "from matplotlib.pylab import date2num\n",
    "\n",
    "import mplfinance as mpf\n",
    "import seaborn as sns\n",
    "%matplotlib inline\n",
    "\n",
    "import matplotlib\n",
    "# matplotlib.use('TkAgg')#必须显式指明matplotlib的后端\n",
    "\n",
    "matplotlib.rcParams['font.sans-serif']=['SimHei']#显示中文标签 \n",
    "matplotlib.rcParams['axes.unicode_minus']=False\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from matplotlib import font_manager as fm, rcParams\n",
    "\n",
    "pd.options.mode.chained_assignment = None\n",
    "\n",
    "\n",
    "\n",
    "pd_data = pd.read_csv(r'../service/requests/datas/000868.csv', parse_dates=['date'], index_col='date')\n",
    "pd_data=pd_data.loc['2022-09']\n",
    "\n",
    "my_color=mpf.make_marketcolors(up='red',down='green',wick='inherit',edge='inherit',volume='inherit')\n",
    "my_style=mpf.make_mpf_style(marketcolors=my_color)\n",
    "\n",
    "hlines=[8.46,7.72]\n",
    "mpf.plot(pd_data,type='candle',mav=(2, 5, 10), volume=True,ylabel_lower='vol',show_nontrading=False,hlines=hlines,style=my_style)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}